package com.atguigu.test;

import org.apache.http.HttpHost;
import org.elasticsearch.action.delete.DeleteRequest;
import org.elasticsearch.action.delete.DeleteResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;

import java.io.IOException;

public class test_es_07_doc_delete {

    public static void main(String[] args) throws IOException {
        //创建es客户端
        RestHighLevelClient esClient = new RestHighLevelClient(RestClient.builder(new HttpHost("127.0.0.1",9200,"http")));

        //删除文档对象
        DeleteRequest deleteRequest = new DeleteRequest();
        deleteRequest.index("user").id("1001");

        //删除文档、发送请求
        DeleteResponse response = esClient.delete(deleteRequest, RequestOptions.DEFAULT);
        System.out.println(response.toString());
        //关闭es客户端
        esClient.close();
    }
}
